#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {
        unordered_set<int> hash(nums1.begin(), nums1.end());
        vector<int> res;
        for (auto num : nums2)
        {
            if (hash.find(num) != hash.end())
            {
                res.push_back(num);
                hash.erase(num);
            }
        }
        return res;
    }
};